home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 235_02 / string.c < prev    next >
Text File  |  1987-06-16  |  896b  |  37 lines

  1. /*  003  14-Feb-87  string.c
  2.  
  3.         Common string related functions.
  4.  
  5.         Copyright (c) 1987 by Blue Sky Software.  All rights reserved.
  6. */
  7.  
  8. #ifndef NULL
  9. #define NULL (0)
  10. #endif
  11.  
  12. /*****************************************************************************
  13.                             S T R C P Y F I L L
  14.  *****************************************************************************/
  15.  
  16. char *
  17. strcpyfill(to,from,fldlen,fillch)      /* copy a string with char fill */
  18. char *from;
  19. register char *to;
  20. int fldlen, fillch;
  21. {
  22.    char *to_where;
  23.    register int len;
  24.  
  25.    to_where = to;
  26.    len = strlen(from);
  27.  
  28.    if (len < fldlen) {
  29.       strncpy(to,from,len);
  30.       for (to+=len; len < fldlen; len++)
  31.          *to++ = fillch;
  32.    } else
  33.      strncpy(to,from,fldlen);
  34.  
  35.    return(to_where);
  36. }
  37.